from PySide6.QtCore import Signal, Slot
from PySide6.QtWidgets import QMainWindow, QApplication, QVBoxLayout, QWidget, QTabWidget, QHBoxLayout, QGridLayout, \
    QMessageBox

from NCView.VisualizerProvider import VisualizerFactory
from NCView.basic import PathVisualizationStrategy
from NCView.manager import VisualizationManager
from NCView.visualizers import VisualizationComponent
from Parser.file_adapters import XMLFileAdapter
from UI.mainWin import Ui_MainWindow
from utils.file_util import FileUtil
import qt_material

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.load_xml_visualizer()
        self.visualizer_manager = VisualizationManager()

    def load_xml_visualizer(self):
        """
        加载XML文件可视化器
        :return:
        """
        # todo 测试时使用 后续需要修改
        # 注册适配器
        self.visualizer_manager.register_adapter("xml" ,XMLFileAdapter())
        # 创建可视化器
        component = VisualizationComponent()
        component.add_strategy(PathVisualizationStrategy())
        # 注册组件
        self.visualizer_manager.register_component("xml", component)
        self.visualizer_manager.visualize_file('./test.xml',file_type="xml")


        

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    qt_material.apply_stylesheet(app, theme="light_pink.xml")
    window = MainWindow()
    window.show()
    sys.exit(app.exec())